<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组下标</title>
</head>
<body>
<script>
    //arr.indexOf(5)
    // let arr = [1,5,"a","o",true,5,[1,2],"9"];
    // function myindexof(arr,obj) {
    //     for (let i = 0;i <arr.length;i++){
    //         if(obj === arr[i]){
    //             return i;
    //             break;
    //         }
    //     }
    //     return -1;
    // }
    // console.log(myindexof(arr,8));

    // arr.lastIndexOf(5)
    let arr = [1,5,"a","o",true,5,[1,2],"9"];
    //let arr = [1,3,5,4,7,5,4];
    function mylastindexof(arr,obj) {
        for (let i = arr.length - 1;i >= 0;i--){
            if(obj === arr[i]){
                return i;
                break;
            }
        }
        return -1;
    }
    console.log(mylastindexof(arr,5));





</script>
</body>
</html>